home *** CD-ROM | disk | FTP | other *** search
- Magic Oracle AppleScript for Java Example 4/9/99
-
- This example demonstrates how to script your Java Application using
- AppleScript. Functionality mimics the old black billiard ball that you
- asked a fortune and then shook vigorously in order to receive a cryptic
- reply.
-
- It also demonstrates how to create a bean info to enhance the
- automatically generated 'aete' created by the introspector.
-
- To submit your question to the "Magic Oracle", type your yes or no
- question in the text field and click the "Ask Oracle" button, press
- return or enter, or grab the ball with your mouse and shake it around
- the screen.
-
- You may also communicate via AppleScript using the Scriptable Text
- Editor.
-
- tell application "Magic Oracle"
- ask Mystic of Main Frame "oracleFrame" parameters {"Is Java cool?"}
- end tell
-
- or using the more straight-forward terminology specified in the
- beanInfo:
-
- tell application "Magic Oracle"
- ask Mystic of frame "oracleFrame" question "Is Java cool?"
- end tell
-
- The application will perform it's magic and return a string as a
- response.
-
- How this works:
-
- The application has a public method that takes a string parameter and
- returns a string.
-
- java.lang.String askOracle( java.lang.String question );
-
- Terminology for this method is in the aete which was automatically
- generated by MRJ, trimmed, edited, and then the 'scsz' resource was
- removed to freeze the terminology.
-
- MainFrameBeanInfo.java contains a property and a method descriptor. The
- property descriptor provides a formal parameter name in the 'aete'. The
- method descriptor provides a more descriptive string for the method
- "askMystic()" in the 'aete'.
-
- If you would like to see the aete generated automatically as specified
- by the BeanInfo, make a copy of the Magic Oracle application. Using
- ResEdit, replace the aete in the application copy with the aete found in
- the MRJ Scripting folder in the MRJ SDK. Make sure that you copy in the
- 'scsz' resource so that generation of the 'aete' is activated. You will
- now be able to open the application dictionary in the Scriptable Text
- Editor and see the results.
-
- For more information on AppleScript for Java, consult Technote 1162:
- Introduction to MRJ Scripting with AppleScript for Java located at:
-
- <http://devworld.apple.com/technotes/java/java-1.html>
-